package com.zhangliuliu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhangliuliu.bean.InsectPestBean;
import com.zhangliuliu.service.InsectPestService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("pest")
public class pestController {
    @Resource
    private InsectPestService insectPestService;
    @RequestMapping("cut")
    public IPage<InsectPestBean> cut(@RequestParam(value = "pageNO",defaultValue = "1") int pageNo,
                                           @RequestParam(value = "pageSize",defaultValue = "4") int pageSize,
                                           @RequestParam("name") String name, @RequestParam("host") String host,
                                           @RequestParam("harm") String harm){

    return insectPestService.cut(pageNo,pageSize,name,host,harm);
    }

    @RequestMapping("add")
    @ResponseBody
    public void addPest(InsectPestBean insectPestBean) {
        insectPestService.addPest(insectPestBean);
    }

    @RequestMapping("selectById")
    @ResponseBody
    public InsectPestBean select(int id) {
        return insectPestService.select(id);
    }
    @RequestMapping("cutByItem")
    @ResponseBody
    IPage<InsectPestBean>cutByItem(@RequestParam (value = "pageNo",defaultValue = "1") int pageNo,
                                   @RequestParam(value = "pageSize",defaultValue = "4") int pageSize,
                                   @RequestParam("name") String name,
                                   @RequestParam("host") String host){
      return   insectPestService.cutByItem(pageNo,pageSize,name,host);
    }


}
